﻿
using CSharpLibs.Annotations;

namespace System.IO
{
	[Builtin]
	public abstract class Stream : Object, IDisposable
	{
		protected Stream()
		{ ;}

		public virtual void Close()
		{ ;}

		public void Dispose()
		{ this.Close(); }

		public abstract int Read(byte[] array, int offset, int count);

		public virtual int ReadByte()
		{
			byte[] buffer = new byte[1];
			if(this.Read(buffer, 0, 1) == 0)
				return -1;

			return buffer[0];
		}

		public abstract long Seek(long offset, SeekOrigin origin);

		public abstract void Write(byte[] buffer, int offset, int count);

		public virtual void WriteByte(byte value)
		{
			byte[] buffer = new byte[1];
			buffer[0] = value;
			this.Write(buffer, 0, 1);
		}

		public abstract long Length { get; }
	}
}
